package com.dwxt.cdms.controller;

import com.dwxt.cdms.base.Page;
import com.dwxt.cdms.entity.Customer;
import com.dwxt.cdms.entity.HeartVoice;
import com.dwxt.cdms.service.HeartVoiceService;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cdms/heart")
@RestController
public class HeartVoiceAdminController {
    @Autowired
    private HeartVoiceService heartVoiceService;

    /**
     * 心电仪详情分页查询
     * @param page
     * @param customer
     * @param isAbnormal
     * @param start
     * @param end
     * @param customerId
     * @return
     */
    @RequestMapping("/selectHeartVoicePage")
    public BaseResult selectHeartVoicePage(Page page, Customer customer, Integer isAbnormal, String start, String end
            ,String customerId){
        return heartVoiceService.selectHeartVoicePage(page,customer,isAbnormal,start,end,customerId);
    }

    /**
     *插入心电数据
     * @param heartVoice
     * @return
     */
    @RequestMapping("/insert")
    public BaseResult insert(HeartVoice heartVoice){
        return heartVoiceService.insert(heartVoice);
    }

    /**
     * 修改心电数据
     * @param heartVoice
     * @return
     */
    @RequestMapping("/update")
    public BaseResult update(HeartVoice heartVoice){
        return heartVoiceService.update(heartVoice);
    }

    /**
     * 删除心电数据
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    public BaseResult delete(Integer id){
        return heartVoiceService.delete(id);
    }

    /**
     * 查询最新的一条数据
     * @param id
     * @return
     */
    @RequestMapping("/selectDetail")
    public BaseResult selectDetail(Integer id){
        return heartVoiceService.selectDetail(id);
    }

    /**
     * 按用户分组查询最新心电数据并分页
     * @param page
     * @param customer
     * @param isAbnormal
     * @param start
     * @param end
     * @return
     */
    @RequestMapping("/selectHeartVoicePageGroup")
    public BaseResult selectHeartVoicePageGroup(Page page, Customer customer, Integer isAbnormal, String start, String end){
        return heartVoiceService.selectHeartVoicePageGroup(page,customer,isAbnormal,start,end);
    }

    /**
     * @Description: TV获取单个用户心电仪数据
     * @param customerId:
     * @param scope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/19
     */
    @RequestMapping("/selectCustomerHeartVoice")
    public BaseResult selectCustomerHeartVoice(@RequestParam(required = true) String customerId,
                                               @RequestParam(required = true,defaultValue = "1")Integer scope){
        return BaseResult.ok(heartVoiceService.selectCustomerHeartVoice(customerId, scope));
    }
}
